import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import topLevelAwait from "vite-plugin-top-level-await"
import Pages from 'vite-plugin-pages'
import * as path from 'path'

const fullReloadAlways = {
  name: 'full-reload-always',
  handleHotUpdate({ server }) {
    server.ws.send({ type: "full-reload" })
    return []
  },
}


// https://vite.dev/config/
export default defineConfig({
  resolve: {
      alias: {
      '@': path.resolve(__dirname, 'src'),
    }
  },
  plugins: [
    vue(),
    topLevelAwait(),
    fullReloadAlways,
    Pages({
      pagesDir: 'src/pages',//使用 Vue3 和 Vite 实现路由自动配置。
      extensions: ['vue'],//只处理vue文件
    }),
  ],
})
